{template 'tpl_header'}
<form id="form1" method="post" action="">
    <div class="weui-panel weui-panel_access">
        <div class="weui-cells" style="margin-top: 0;font-size: 14px;">
            <div class="weui-cell weui-cell_access">
                <div class="weui-cell__hd"><label class="weui-label">证件类型</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" id="job" name="certificate_type" type="text" placeholder="请选择证件类型" value="{php echo ($insured['certificate_type'] == '1')?'护照':(($insured['certificate_type'] == '2')?'身份证':''); }">
                </div>
                <div class="weui-cell__ft">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">证件号码</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" name="certificate_no" placeholder="请输入证件号码" type="text" value="{$insured['certificate_no']}">
                </div>
                <div class="weui-cell__ft">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">姓名</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-input" name="real_name" placeholder="请输入姓名" type="text" value="{$insured['real_name']}">
                </div>
                <div class="weui-cell__ft">
                </div>
            </div>
        </div>
    </div>

    <div class='insured_btn'>
        <button id="sub" type="button" class="weui-btn weui-btn_primary">保存</button>
    </div>
</form>
{template 'tpl_footer'}
<script>
    $("#job").select({
        title: "请选择证件类型",
        items: ["身份证", "护照"],
        onChange: function (d) {
            console.log(this, d);
        },
        onClose: function () {
            console.log("close");
        },
        onOpen: function () {
            console.log("open");
        },
    });
    $(function () {
        $('#sub').click(function () {
            var certificate_type = $('input[name="certificate_type"]').val();
            var certificate_no = $('input[name="certificate_no"]').val();
            var real_name = $('input[name="real_name"]').val();
            if(certificate_type == ""){
                $.toast('请选择证件类型', "cancel");
                return false;
            }

            if(certificate_no == ""){
                $.toast('请填写证件号码', "cancel");
                return false;
            }

            if(real_name == ""){
                $.toast('请选择姓名', "cancel");
                return false;
            }

            $("#form1").submit();
        });
    });
</script>